package com.yanggeng.demo.beginnerguidedemo.activity;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;

import com.amap.api.services.help.Inputtips;
import com.amap.api.services.help.InputtipsQuery;
import com.amap.api.services.help.Tip;
import com.yanggeng.demo.beginnerguidedemo.R;
import com.yanggeng.demo.beginnerguidedemo.TestApplication;
import com.yanggeng.demo.beginnerguidedemo.activity.BaseActivity;

import java.util.List;

/**
 * Created by yanggeng on 2017/9/18.
 */

public class MapWebActivity extends BaseActivity implements Inputtips.InputtipsListener {

    private EditText etStart, etDest;
    private WebView webView;

    private Context context;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map_webview);
        hideToolbar();
        context = this;
        etStart = (EditText) findViewById(R.id.et_start);
        etDest = (EditText) findViewById(R.id.et_dest);
        webView = (WebView) findViewById(R.id.web_view);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebViewClient(new WebViewClient());
        if (!TextUtils.isEmpty(TestApplication.getApplication().getAddress())) {
            etStart.setText("我的位置");
        }


    }

    @Override
    public void onGetInputtips(List<Tip> list, int i) {

    }

    class TipsTextWatcher implements TextWatcher {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            InputtipsQuery iq = new InputtipsQuery(s.toString().trim(), TestApplication.getApplication().getCity());
            iq.setCityLimit(true);
            Inputtips inputtips = new Inputtips(context, iq);
            inputtips.requestInputtipsAsyn();
        }
    }
}
